package azheng.apps.starclouddemo.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

import azheng.apps.starclouddemo.R;

public class ViView extends View {
    Paint paint;
    Context context;

    //构造方法
    public ViView(Context context) {
        super(context);
    }

    public ViView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ViView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);

    }

    /*绘图*/
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        //得到屏幕宽高
        int width = getWidth();
        int radius = width - 450 / 2;
        int height = getHeight();
// 创建画笔 
        Paint paint1 = new Paint();
        Paint paint2 = new Paint();
        Paint paint3 = new Paint();
// 消除锯齿 
        paint1.setAntiAlias(true);
        paint2.setAntiAlias(true);
        paint3.setAntiAlias(true);
        //画笔颜色
        paint1.setColor(getResources().getColor(R.color.colorCanvas));
        paint2.setColor(getResources().getColor(R.color.colorCanvas));
        paint3.setColor(getResources().getColor(R.color.colorCanvas));

        //设置圆环宽度
        paint1.setStrokeWidth(10);
        paint2.setStrokeWidth(10);
        paint3.setStrokeWidth(10);
        //空心效果
        paint1.setStyle(Paint.Style.STROKE);
        paint2.setStyle(Paint.Style.STROKE);
        paint3.setStyle(Paint.Style.STROKE);

        canvas.drawCircle(width / 2, height / 2, 250, paint1);
        canvas.drawCircle(width / 2, height / 2, 300, paint2);
        canvas.drawCircle(width / 2, height / 2, 400, paint3);


    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return super.onTouchEvent(event);
    }
} 